<html><head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta content="text/javascript" http-equiv="content-script-type">
<title>tango.io.Print</title>

<link rel="stylesheet" type="text/css" href="css/style.css">
<!--[if lt IE 7]><link rel="stylesheet" type="text/css" href="css/ie56hack.css"><![endif]-->
<script language="JavaScript" src="js/util.js" type="text/javascript"></script>
<script language="JavaScript" src="js/tree.js" type="text/javascript"></script>
<script language="JavaScript" src="js/explorer.js" type="text/javascript"></script>
<script>
function anchorFromTitle(title, path, ext) {
  var url = path + title + "." + ext;
  document.write("<a href='" + url + "'>" + title + "</a>");
  }
</script>
</head><body>
<div id="tabarea"></div><div id="explorerclient"></div>
<div id="content"><script>explorer.initialize("tango.io.Print");</script>
        <table class="content">
                <tr><td id="docbody"><h1><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/io/Print.d?rev=3327">tango.io.Print</a></h1>
                
<b>License:</b><br>
BSD style: see <a href="http://www.dsource.org/projects/tango/wiki/LibraryLicense">license.txt</a><br><br>
<b>Version:</b><br>
Feb 2007: Separated from Stdout<br><br>
<b>author:</b><br>Kris<br><br>
<script>explorer.outline.incSymbolLevel();</script>
<dl>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>class <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/io/Print.d?rev=3327#L89">Print</a></span>
<script>explorer.outline.addDecl('Print');</script>(T) : OutputStream;</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">A bridge between a Layout instance and a Buffer. This is used for
        the Stdout &amp; Stderr globals, but can be used for general purpose
        buffer-formatting as desired. The Template type 'T' dictates the
        text arrangement within the target buffer ~ one of char, wchar or
        dchar &#40;utf8, utf16, or utf32&#41;. 
        
        Print exposes this style of usage:
        <pre class="d_code">

        <span class="k">auto</span> <span class="i">print</span> = <span class="k">new</span> <span class="i">Print</span>!(<span class="k">char</span>) (...);

        <span class="i">print</span> (<span class="sl">"hello"</span>);                        =&gt; <span class="i">hello</span>
        <span class="i">print</span> (<span class="n">1</span>);                              =&gt; <span class="n">1</span>
        <span class="i">print</span> (<span class="n">3.14</span>);                           =&gt; <span class="n">3.14</span>
        <span class="i">print</span> (<span class="cl">'b'</span>);                            =&gt; <span class="i">b</span>
        <span class="i">print</span> (<span class="n">1</span>, <span class="n">2</span>, <span class="n">3</span>);                        =&gt; <span class="n">1</span>, <span class="n">2</span>, <span class="n">3</span>         
        <span class="i">print</span> (<span class="sl">"abc"</span>, <span class="n">1</span>, <span class="n">2</span>, <span class="n">3</span>);                 =&gt; <span class="i">abc</span>, <span class="n">1</span>, <span class="n">2</span>, <span class="n">3</span>        
        <span class="i">print</span> (<span class="sl">"abc"</span>, <span class="n">1</span>, <span class="n">2</span>) (<span class="sl">"foo"</span>);            =&gt; <span class="i">abc</span>, <span class="n">1</span>, <span class="n">2f</span><span class="i">oo</span>        
        <span class="i">print</span> (<span class="sl">"abc"</span>) (<span class="sl">"def"</span>) (<span class="n">3.14</span>);           =&gt; <span class="i">abcdef3</span><span class="n">.14</span>

        <span class="i">print</span>.<span class="i">format</span> (<span class="sl">"abc {}"</span>, <span class="n">1</span>);             =&gt; <span class="i">abc</span> <span class="n">1</span>
        <span class="i">print</span>.<span class="i">format</span> (<span class="sl">"abc {}:{}"</span>, <span class="n">1</span>, <span class="n">2</span>);       =&gt; <span class="i">abc</span> <span class="n">1</span>:<span class="n">2</span>
        <span class="i">print</span>.<span class="i">format</span> (<span class="sl">"abc {1}:{0}"</span>, <span class="n">1</span>, <span class="n">2</span>);     =&gt; <span class="i">abc</span> <span class="n">2</span>:<span class="n">1</span>
        <span class="i">print</span>.<span class="i">format</span> (<span class="sl">"abc "</span>, <span class="n">1</span>);               =&gt; <span class="i">abc</span>
        
</pre></font><br><br>
<font color="black">Note that the last example does not throw an exception. There
        are several use-cases where dropping an argument is legitimate,
        so we're currently not enforcing any particular trap mechanism.<br><br>        Flushing the output is achieved through the flush&#40;&#41; method, or
        via an empty pair of parens: 
        <pre class="d_code">

        <span class="i">print</span> (<span class="sl">"hello world"</span>) ();
        <span class="i">print</span> (<span class="sl">"hello world"</span>).<span class="i">flush</span>;

        <span class="i">print</span>.<span class="i">format</span> (<span class="sl">"hello {}"</span>, <span class="sl">"world"</span>) ();
        <span class="i">print</span>.<span class="i">format</span> (<span class="sl">"hello {}"</span>, <span class="sl">"world"</span>).<span class="i">flush</span>;
        
</pre>
        
        Special character sequences, such as "\n", are written directly to
        the output without any translation &#40;though an output-filter could
        be inserted to perform translation as required&#41;. Platform-specific 
        newlines are generated instead via the newline&#40;&#41; method, which also 
        flushes the output when configured to do so:
        <pre class="d_code">

        <span class="i">print</span> (<span class="sl">"hello "</span>) (<span class="sl">"world"</span>).<span class="i">newline</span>;
        <span class="i">print</span>.<span class="i">format</span> (<span class="sl">"hello {}"</span>, <span class="sl">"world"</span>).<span class="i">newline</span>;
        <span class="i">print</span>.<span class="i">formatln</span> (<span class="sl">"hello {}"</span>, <span class="sl">"world"</span>);
        
</pre><br><br>        The format&#40;&#41; method supports the range of formatting options 
        exposed by tango.text.convert.Layout and extensions thereof; 
        including the full I18N extensions where configured in that 
        manner. To create a French instance of Print:
        <pre class="d_code">

        <span class="k">import</span> <span class="i">tango</span>.<span class="i">text</span>.<span class="i">locale</span>.<span class="i">Locale</span>;

        <span class="k">auto</span> <span class="i">locale</span> = <span class="k">new</span> <span class="i">Locale</span> (<span class="i">Culture</span>.<span class="i">getCulture</span> (<span class="sl">"fr-FR"</span>));
        <span class="k">auto</span> <span class="i">print</span> = <span class="k">new</span> <span class="i">Print</span>!(<span class="k">char</span>) (<span class="i">locale</span>, ...);
        
</pre><br><br>        Note that Print is *not* intended to be thread-safe. Use either
        tango.util.log.Trace or the standard logging facilities in order 
        to enable atomic console I/O
        
</font><br><br>
<script>explorer.outline.incSymbolLevel();</script>
<dl>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li><span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/io/Print.d?rev=3327#L110">this</a></span>
<script>explorer.outline.addDecl('this');</script>(Layout!(T) <span class="funcparam">convert</span>, OutputStream <span class="funcparam">output</span>, T[] <span class="funcparam">eol</span> = Eol);</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Construct a Print instance, tying the provided stream
                to a layout formatter</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>Print <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/io/Print.d?rev=3327#L126">format</a></span>
<script>explorer.outline.addDecl('format');</script>(T[] <span class="funcparam">fmt</span>, ...); [final]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Layout using the provided formatting specification</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>Print <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/io/Print.d?rev=3327#L138">formatln</a></span>
<script>explorer.outline.addDecl('formatln');</script>(T[] <span class="funcparam">fmt</span>, ...); [final]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Layout using the provided formatting specification</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>Print <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/io/Print.d?rev=3327#L151">print</a></span>
<script>explorer.outline.addDecl('print');</script>(...); [final]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Unformatted layout, with commas inserted between args. 
                Currently supports a maximum of 24 arguments</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>Print <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/io/Print.d?rev=3327#L173">newline</a></span>
<script>explorer.outline.addDecl('newline');</script>(); [final]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Output a newline and optionally flush</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>Print <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/io/Print.d?rev=3327#L188">flush</a></span>
<script>explorer.outline.addDecl('flush');</script>(bool <span class="funcparam">yes</span>); [final]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Control implicit flushing of newline&#40;&#41;, where true enables
                flushing. An explicit flush&#40;&#41; will always flush the output.</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>OutputStream <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/io/Print.d?rev=3327#L200">stream</a></span>
<script>explorer.outline.addDecl('stream');</script>(); [final]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Return the associated output stream</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>Print <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/io/Print.d?rev=3327#L211">stream</a></span>
<script>explorer.outline.addDecl('stream');</script>(OutputStream <span class="funcparam">output</span>); [final]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Set the associated output stream</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>Layout!(T) <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/io/Print.d?rev=3327#L223">layout</a></span>
<script>explorer.outline.addDecl('layout');</script>(); [final]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Return the associated Layout</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>Print <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/io/Print.d?rev=3327#L234">layout</a></span>
<script>explorer.outline.addDecl('layout');</script>(Layout!(T) <span class="funcparam">layout</span>); [final]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Set the associated Layout</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>uint <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/io/Print.d?rev=3327#L246">sink</a></span>
<script>explorer.outline.addDecl('sink');</script>(T[] <span class="funcparam">s</span>); [private, final]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Sink for passing to the formatter</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>IConduit <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/io/Print.d?rev=3327#L262">conduit</a></span>
<script>explorer.outline.addDecl('conduit');</script>();</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">OutputStream Interface </font><br><br>
<font color="black">Return the host conduit<br><br></font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>uint <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/io/Print.d?rev=3327#L277">write</a></span>
<script>explorer.outline.addDecl('write');</script>(void[] <span class="funcparam">src</span>);</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Write to conduit from a source array. The provided src
                content will be written to the conduit.</font><br><br>
<font color="black">Returns the number of bytes written from src, which may
                be less than the quantity provided<br><br></font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>OutputStream <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/io/Print.d?rev=3327#L288">flush</a></span>
<script>explorer.outline.addDecl('flush');</script>(); [final]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Flush the output stream</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>OutputStream <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/io/Print.d?rev=3327#L301">copy</a></span>
<script>explorer.outline.addDecl('copy');</script>(InputStream <span class="funcparam">src</span>);</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Transfer the content of another conduit to this one. Returns
                a reference to this class, and throws IOException on failure.</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>void <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/io/Print.d?rev=3327#L313">close</a></span>
<script>explorer.outline.addDecl('close');</script>();</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Close the output</font><br><br></dd></dl>
<script>explorer.outline.decSymbolLevel();</script></dd></dl>
<script>explorer.outline.decSymbolLevel();</script></td></tr>
                <tr><td id="docfooter">
                        Copyright (c) 2007 Kris Bell. All rights reserved :: page rendered by CandyDoc. Generated by <a href="http://code.google.com/p/dil">dil</a> on Tue Mar  4 22:45:33 2008.
                </td></tr>
        </table>
</div>
<script></script>
</body></html>